import allure
from page_base.page_base import Base
# from page_element.el_A3mall import *
from page_element.roncoo_sett import *
from page_object.roncoo_login import RoncooLogin
from utils.timer import sleep
import logging



class SettSearch(RoncooLogin):
    def sett_search(self,username,expected,casename):
        self.roncoo_login()
        self.click(sett_pe.sett_ele)
        sleep(3)
        self.click(sett_pe.sett_ele_loc)
        sleep(3)
        self.send_keys(sett_pe.search_input,username)
        sleep(3)
        self.click(sett_pe.search_btn)
        with allure.step('验证结算搜索是否成功'):
            if '成功' in casename:
                dy = self.text(sett_pe.username_dy)
                assert expected  == dy ,f'断言用户名'
            else:
                dy = self.text(sett_pe.nodata_dy)
                assert expected == dy ,f'暂无数据'
    def sett_page(self):
        self.roncoo_login()
        self.click(sett_pe.sett_ele)
        sleep(3)
        self.click(sett_pe.sett_ele_loc)
        sleep(3)
        self.clear(sett_pe.currentpage_loc)
        self.send_keys(sett_pe.currentpage_loc,'1')
        sleep(2)
    #发起结算
    def sett_getamount(self):
        self.roncoo_login()
        self.click(sett_pe.sett_ele)
        sleep(3)
        self.click(sett_pe.sett_ele_loc)
        sleep(3)
        self.click(sett_pe.sett_btn)
        #输入用户编号
        self.send_keys(sett_pe.sett_user,'81941866028824989697')
        #输入用户名
        self.send_keys(sett_pe.sett_username,'555')
        #点击获取可结算余额
        self.click(sett_pe.getsett_loc)
        # 可结算余额--输入
        self.send_keys(sett_pe.setamount_loc, '0')
        #点击提交按钮
        self.click(sett_pe.submit_loc)
        #断言操作成功
        dy = self.text(sett_pe.sucess_loc)
        assert  '成功' in dy ,'发起结算成功'
        sleep(5)











